﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace WebComponents.Mail
{
    public class Send
    {
        public static void SendMail(List<IMail> mail)
        {
            foreach (IMail m in mail)
            {
                MailMessage msgMail = new MailMessage(m.From, m.To);
                if (m.Cc != null)
                    msgMail.CC.Add(m.Cc);
                if (m.Bcc != null)
                    msgMail.Bcc.Add(m.Bcc);
                msgMail.Subject = m.Subject;
                msgMail.Body = m.Body;
                if (m.Format != null)
                    if (m.Format.ToLower() == "html")
                        msgMail.IsBodyHtml = true;
                SmtpClient stmp = new SmtpClient();
                stmp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
                stmp.Send(msgMail);
            }
        }

    }
}
